local fire_attack = fk.CreateSkill {
  name = "iberia__fire_attack_skill",
}

Fk:loadTranslationTable{ ["iberia__fire_attack"] = "火攻" }

fire_attack:addEffect("cardskill", {
  prompt = "#fire_attack_skill",
  target_num = 1,
  mod_target_filter = function(self, _, to_select)
    return not to_select:isKongcheng()
  end,
  target_filter = Util.CardTargetFilter,
  on_effect = function(self, room, effect)
    local from = effect.from
    local to = effect.to
    if to:isKongcheng() then return end

    local params = { ---@type AskToCardsParams
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = "iberia__fire_attack",
      cancelable = false,
      pattern = ".|.|.|hand",
      prompt = "#fire_attack-show:" .. from.id
    }
    local showCard = room:askToCards(to, params)[1]
    to:showCards(showCard)
    local _, ret = room:askToUseActiveSkill(from, {
      skill_name = "fire_attack_choose",
      cancelable = true,
      extra_data = { fire_attack_suit = Fk:getCardById(showCard).suit },
      prompt = "#fire_attack-discard:" .. to.id .. "::" .. Fk:getCardById(showCard):getSuitString(),
    })
    if ret then
      if ret.interaction == "lose_hp" then
        room:loseHp(from, 1, "iberia__fire_attack")
      elseif ret.cards then
        room:throwCard(ret.cards, "iberia__fire_attack", from, from)
      end
      if to:isAlive() then
        room:damage({
          from = from,
          to = to,
          card = effect.card,
          damage = 1,
          damageType = fk.FireDamage,
          skillName = "iberia__fire_attack",
        })
      end
    end
  end
})

return fire_attack
